package com.tcoiss.common.component.factory;

import com.tcoiss.common.component.dataentity.TypesContainer;
import com.tcoiss.common.core.constant.ServiceNameConstants;

import java.util.HashMap;
import java.util.Map;

public class InvolerHelperFactory {

//    @Autowired
//    private static RemoteApiService remoteApiService;
//
//    @Autowired
//    private static RemoteDataFactoryService remoteDataFactoryService;
//
//    @Autowired
//    private static RemoteLogService remoteLogService;

    private static Map<String, String> serviceMap = new HashMap();

    public static Object getService(String serviceName) {
        String className =  serviceMap.get(serviceName);
        if (className == null) {
            throw new RuntimeException(String.format("%s对应的服务实现未找到", new Object[]{serviceName}));
        } else {
            return TypesContainer.getOrRegisterSingletonInstance(className);
        }
    }



    static {
        serviceMap.put(ServiceNameConstants.LOG_SERVICE, "com.tcoiss.common.component.api.RemoteLogService");
        serviceMap.put(ServiceNameConstants.WEBAPI_SERVICE, "com.tcoiss.common.component.api.RemoteApiService");
        serviceMap.put(ServiceNameConstants.DATA_SERVICE, "com.tcoiss.common.component.api.RemoteDataFactoryService");
    }

}
